package com.itboye.textileexpes.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.interfaces.IUserRepository;
import com.itboye.textileexpes.beans.AppUpdateBean;
import com.itboye.textileexpes.beans.CollectionBeans;
import com.itboye.textileexpes.beans.CollectionBeans.ColleBeansList;
import com.itboye.textileexpes.beans.ColletionFenyeBeans;
import com.itboye.textileexpes.beans.ForresterBeans;
import com.itboye.textileexpes.beans.PersonDataBean;
import com.itboye.textileexpes.beans.ShopCharRootBean;
import com.itboye.textileexpes.interfaces.IAppUpdate;
import com.itboye.textileexpes.interfaces.ICategory;
import com.itboye.textileexpes.json.ByJsonRequest.Builder;
import com.itboye.textileexpres.base.BaseErrorListener;
import com.itboye.textileexpres.base.BaseNetRepository;
import com.itboye.textileexpres.base.BaseSuccessReqListener;

public class CategoryRepository extends BaseNetRepository implements
ICategory<ForresterBeans> {
	/***
	 * 查询类目
	 */
	public static final String Category = "By_Category_queryMainCategory";
//收藏类目
	public static final String Collection="By_Favorites_cate";
	//分頁
	public static final String Collectioncate="By_Favorites_query";
	//购物城
	public static final String ShopChar="By_ShoppingCart_query";
	
	//照片查询
	public static final String Photo="By_GoodsFeedback_add";
	public CategoryRepository(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(ForresterBeans model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delete(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ForresterBeans model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ForresterBeans>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");

		(new Builder<ForresterBeans>())
				.setTypeVerParamsAndReturnClass(Category, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<ForresterBeans>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();

	}

	@Override
	public List<ForresterBeans> query(ForresterBeans model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onColletion(String uid) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<List<CollectionBeans>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");
		map.put("uid",uid);

		(new Builder<List<CollectionBeans>>())
				.setTypeVerParamsAndReturnClass(Collection, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<List<CollectionBeans>>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void onColletionCate(String id,String uid) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<ColletionFenyeBeans>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");
		map.put("id",id);
		map.put("uid",uid);

		(new Builder<ColletionFenyeBeans>())
				.setTypeVerParamsAndReturnClass(Collectioncate, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<ColletionFenyeBeans>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void onShopcar(String uid) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<List<ShopCharRootBean>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");
		map.put("uid",uid);

		(new Builder<List<ShopCharRootBean>>())
				.setTypeVerParamsAndReturnClass(ShopChar, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<List<ShopCharRootBean>>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void onPhoto(String img_ids, String uid, String desc,
			String contact_addr) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");
		map.put("uid",uid);
		map.put("desc",desc);
		map.put("img_ids", img_ids);
		map.put("contact_addr",contact_addr);

		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(Photo, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}

}
